//package com.gears_software.sxdc.dccx.ui.activity;
//
//import android.Manifest;
//import android.content.Context;
//import android.content.Intent;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.graphics.drawable.BitmapDrawable;
//import android.graphics.drawable.Drawable;
//import android.net.Uri;
//import android.os.Build;
//import android.os.Bundle;
//import android.os.Environment;
//import android.provider.MediaStore;
//import android.support.annotation.NonNull;
//import android.support.v4.content.FileProvider;
//import android.support.v4.content.PermissionChecker;
//import android.support.v7.app.AppCompatActivity;
//import android.util.Log;
//import android.view.View;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//
//
//import com.gears_software.sxdc.dccx.R;
//import com.gears_software.sxdc.dccx.application.DCCXApplication;
//import com.gears_software.sxdc.dccx.ui.util.popu.PhotoPopup;
//import com.makeramen.roundedimageview.RoundedImageView;
//import com.sdsmdg.tastytoast.TastyToast;
//import com.yanzhenjie.permission.AndPermission;
//import com.yanzhenjie.permission.PermissionListener;
//import com.yanzhenjie.permission.PermissionNo;
//import com.yanzhenjie.permission.PermissionYes;
//import com.yanzhenjie.permission.Rationale;
//import com.yanzhenjie.permission.RationaleListener;
//
//import org.androidannotations.annotations.AfterViews;
//import org.androidannotations.annotations.App;
//import org.androidannotations.annotations.Click;
//import org.androidannotations.annotations.EActivity;
//import org.androidannotations.annotations.ViewById;
//
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.List;
//
//import me.iwf.photopicker.PhotoPicker;
//import me.iwf.photopicker.PhotoPreview;
//import me.iwf.photopicker.utils.FileUtils;
//
///**
// * Created by chezhenzhen on 2017/6/6.
// */
//@EActivity(R.layout.activity_my)
//public class MyActivity extends AppCompatActivity implements PhotoPopup.PhotocallBack {
//    @App
//    DCCXApplication app;
//    @ViewById
//    TextView back_icon;
//    @ViewById
//    TextView actionbar_title;
//    @ViewById
//    TextView right_icon;
//    @ViewById
//    TextView txt_right_icon1;
//    @ViewById
//    TextView txt_qianbao;
//    @ViewById
//    TextView txt_xingcheng;
//    @ViewById
//    TextView txt_duijiang;
//    @ViewById
//    TextView txt_yaoqing;
//    @ViewById
//    TextView txt_address;
//    @ViewById
//    TextView txt_dengji;
//    @ViewById
//    TextView txt_message_center;
//    @ViewById
//    TextView txt_tiaokuan;
//    @ViewById
//    TextView txt_about;
//    @ViewById
//    TextView txt_fankui;
//    @ViewById
//    TextView txt_shiming;
//    @ViewById
//    TextView txt_chezhu;
//    @ViewById
//    TextView txt_cheliang;
//    @ViewById
//    TextView txt_right_icon2;
//    @ViewById
//    TextView txt_right_icon3;
//    @ViewById
//    TextView txt_right_icon4;
//    @ViewById
//    TextView txt_right_icon5;
//    @ViewById
//    TextView txt_right_icon6;
//    @ViewById
//    TextView txt_right_icon7;
//    @ViewById
//    TextView txt_right_icon8;
//    @ViewById
//    TextView txt_right_icon9;
//    @ViewById
//    TextView txt_right_icon10;
//    @ViewById
//    TextView txt_right_icon12;
//    @ViewById
//    TextView txt_right_icon13;
//    @ViewById
//    TextView txt_right_icon14;
//    @ViewById
//    TextView txt_right_icon15;
//    @ViewById
//    ImageView img_avatar;
//    @ViewById
//    LinearLayout ly_avatar;
//
//    private String sdPath;//SD卡的路径
//    private String picPath;//图片存储路径
//    private static int REQUEST_ORIGINAL = 2; // 请求原图信号标识
//
//    private ArrayList<String> selectedPhotos = new ArrayList<>();
//    Context context;
//
//    @AfterViews
//    void created() {
//        context = this;
//        initIconFont();
//        //获取SD卡的路径
//        sdPath = Environment.getExternalStorageDirectory().getPath();
//        picPath = sdPath + "/" + String.valueOf(System.currentTimeMillis()) + ".png";
//    }
//
//    void initIconFont() {
//        actionbar_title.setText("我的");
//        back_icon.setVisibility(View.VISIBLE);
//        back_icon.setText(R.string.back_icon);
//        back_icon.setTypeface(app.iconfont);
//        right_icon.setVisibility(View.GONE);
//        txt_right_icon1.setTypeface(app.iconfont);
//        txt_qianbao.setTypeface(app.iconfont);
//        txt_xingcheng.setTypeface(app.iconfont);
//        txt_duijiang.setTypeface(app.iconfont);
//        txt_yaoqing.setTypeface(app.iconfont);
//        txt_address.setTypeface(app.iconfont);
//        txt_dengji.setTypeface(app.iconfont);
//        txt_tiaokuan.setTypeface(app.iconfont);
//        txt_message_center.setTypeface(app.iconfont);
//        txt_about.setTypeface(app.iconfont);
//        txt_fankui.setTypeface(app.iconfont);
//        txt_shiming.setTypeface(app.iconfont);
//        txt_chezhu.setTypeface(app.iconfont);
//        txt_cheliang.setTypeface(app.iconfont);
//        txt_right_icon2.setTypeface(app.iconfont);
//        txt_right_icon3.setTypeface(app.iconfont);
//        txt_right_icon4.setTypeface(app.iconfont);
//        txt_right_icon5.setTypeface(app.iconfont);
//        txt_right_icon6.setTypeface(app.iconfont);
//        txt_right_icon7.setTypeface(app.iconfont);
//        txt_right_icon8.setTypeface(app.iconfont);
//        txt_right_icon9.setTypeface(app.iconfont);
//        txt_right_icon10.setTypeface(app.iconfont);
//        txt_right_icon12.setTypeface(app.iconfont);
//        txt_right_icon13.setTypeface(app.iconfont);
//        txt_right_icon14.setTypeface(app.iconfont);
//        txt_right_icon15.setTypeface(app.iconfont);
//    }
//
//    @Click
//    void re_wallet() {
//        Intent intent = new Intent(this, MyWalletActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_trip() {
//        Intent intent = new Intent(this, MyTripActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_chezhu() {
//        Intent intent = new Intent(this, JiaShiZhengActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_cars() {
//        Intent intent = new Intent(this, MyCarActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_shiming() {
//        Intent intent = new Intent(this, ShiMingActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_feedback() {
//        Intent intent = new Intent(this, FeedBackActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_header() {
//        PhotoPopup popup = new PhotoPopup(this);
//        popup.setPhotoClick(this);
//        popup.showPopupWindow();
//    }
//
//    @Click
//    void re_address() {
//        Intent intent = new Intent(this, UsualAddressActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void re_dengji() {
//        Intent intent = new Intent(this, RegisterRidingInformationActivity_.class);
//        startActivity(intent);
//    }
//
//    @Click
//    void back_icon() {
//        this.finish();
//    }
//
//    @Override
//    public void photoClick(int photoTag) {
//        //拍照
//        if (photoTag == 0) {
//            AndPermission.with(this)
//                    .requestCode(100)
//                    .permission(Manifest.permission.CAMERA)
//                    .callback(listener)
//                    .rationale(new RationaleListener() {
//                        @Override
//                        public void showRequestPermissionRationale(int requestCode, Rationale rationale) {
//                            // 这里的对话框可以自定义，只要调用rationale.resume()就可以继续申请。
//                            AndPermission.rationaleDialog(context, rationale).
//                                    show();
//                        }
//                    })
//                    .start();
//
//        } else if (photoTag == 1) { //从手机相册选择
//            AndPermission.with(this)
//                    .requestCode(200)
//                    .permission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)
//                    .callback(listener)
//                    .rationale(new RationaleListener() {
//                        @Override
//                        public void showRequestPermissionRationale(int requestCode, Rationale rationale) {
//                            // 这里的对话框可以自定义，只要调用rationale.resume()就可以继续申请。
//                            AndPermission.rationaleDialog(context, rationale).
//                                    show();
//                        }
//                    })
//                    .start();
//
//        }
//    }
//
//    private void openCreame() {
//
//        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//        Uri uri;
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//            uri = FileProvider.getUriForFile(this, this.getPackageName() + ".provider", new File(picPath));
//        } else {
//            uri = Uri.fromFile(new File(picPath));
//        }
//        //为拍摄的图片指定一个存储的路径
//        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
//        startActivityForResult(intent, REQUEST_ORIGINAL);
//    }
//
////    private void openPhoto() {
////        PhotoPicker.builder()
////                .setPhotoCount(1)
////                .setShowCamera(true)
////                .setPreviewEnabled(true).start(this);
////    }
//
//    private PermissionListener listener = new PermissionListener() {
//        @Override
//        public void onSucceed(int requestCode, List<String> grantedPermissions) {
//            // 权限申请成功回调。
//            if (requestCode == 100) {
//                //打开相机
//                openCreame();
//            } else if (requestCode == 200) {
//                //打开相册
//                //openPhoto();
//            }
//        }
//
//        @Override
//        public void onFailed(int requestCode, List<String> deniedPermissions) {
//            // 权限申请失败回调。
//            if (requestCode == 100) {
//                TastyToast.makeText(context, "获取系统相机权限失败", TastyToast.LENGTH_SHORT, TastyToast.DEFAULT);
//
//            } else if (requestCode == 200) {
//                TastyToast.makeText(context, "获取系统上的照片、媒体内容和文件权限失败", TastyToast.LENGTH_SHORT, TastyToast.DEFAULT);
//
//            }
//        }
//    };
//
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode == RESULT_OK) {
//            //相册返回结果
//            if (requestCode == PhotoPicker.REQUEST_CODE || requestCode == PhotoPreview.REQUEST_CODE) {
//                List<String> photos = null;
//                if (data != null) {
//                    photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);
//                    Log.d("photos", photos.toString());
//                }
//                selectedPhotos.clear();
//                if (photos != null) {
//                    selectedPhotos.addAll(photos);
//                    picPath = photos.get(0);
//                    showImageAvatar();
//                }
//            } else if (requestCode == REQUEST_ORIGINAL) {//拍照返回结果
//
//                showImageAvatar();
//
//
//            }
//        }
//    }
//
//    private void showImageAvatar() {
//        FileInputStream fis = null;
//
//        try {
//            Log.e("picPath", picPath);
//            //把图片转化为字节流
//            fis = new FileInputStream(picPath);
//            //把流转化图片
//            Bitmap bitmap = BitmapFactory.decodeStream(fis);
//            Drawable drawable = new BitmapDrawable(bitmap);
//            img_avatar.setImageDrawable(drawable);
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } finally {
//            try {
//                fis.close();//关闭流
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//    }
//
//    @Click
//   void ly_avatar() {
//        PhotoPreview.builder().setPhotos(selectedPhotos).start(this);
//   }
//}
